home *** CD-ROM | disk | FTP | other *** search
- /*
- * GUI Designed by : Will Bow
- */
-
- #include <dos/dos.h>
- #include <exec/types.h>
- #include <exec/libraries.h>
- #include <libraries/commodities.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <functions.h>
-
- #include <local/libraries/reqtools.h>
-
- /*
- * Application specific include files
- */
- #include "ups.h"
- #include "main.h"
- #include "database.h"
- #include "functions.h"
-
- static UBYTE *VersTag = "\0$VER: UPSey 1.0pd (1.07.94)";
-
- /* System library bases */
- extern struct Library *SysBase, *DOSBase;
- struct IntuitionBase *IntuitionBase = NULL;
- struct GfxBase *GfxBase = NULL;
- struct Library *GadToolsBase = NULL;
- struct Library *DiskFontBase = NULL;
- struct Library *UtilityBase = NULL;
- struct Library *CxBase = NULL;
- struct Library *IconBase = NULL;
- struct Library *AslBase = NULL;
- struct ReqToolsBase *ReqToolsBase = NULL;
-
- #define EVT_HOTKEY 1L
-
-
- BYTE donotwait = 0;
- BYTE cx_popup = 0;
- char *cx_popkey = NULL;
- char *database = NULL;
-
- struct List record_list;
-
- struct MsgPort *broker_mp;
-
- CxObj *broker, *filter, *sender, *translate;
-
- ULONG intuisigflag = 0L, cxsigflag = 0L;
-
- struct NewBroker newbroker =
- {
- NB_VERSION,
- "UPSey", /* string to identify this broker */
- " UPSey: Giftware from BOTH Software",
- " Translates Zip Codes to UPS Zones",
- NBU_UNIQUE | NBU_NOTIFY, /* Don't want any new commodities
- * starting with this name. If someone
- * tries it, let me know */
- COF_SHOW_HIDE,
- 0,
- 0,
- 0
- };
-
-
- LONG
- ProcessCXMsg (void)
- {
- extern struct MsgPort *broker_mp;
- extern CxObj *broker;
-
- CxMsg *msg;
-
- LONG returnvalue = 1L;
-
- while (msg = (CxMsg *) GetMsg (broker_mp))
- {
- ULONG msgid = CxMsgID (msg);
- ULONG msgtype = CxMsgType (msg);
-
- ReplyMsg ((struct Message *) msg);
-
- switch (msgtype)
- {
- case CXM_IEVENT:
-
- switch (msgid)
- {
- case EVT_HOTKEY:
- Project0OpenWindow ();
- break;
-
- default:
- break;
- }
- break;
-
- case CXM_COMMAND:
-
- switch (msgid)
- {
- case CXCMD_APPEAR:
- Project0OpenWindow ();
- break;
-
- case CXCMD_DISAPPEAR:
- Project0CloseWindow ((struct IntuiMessage *) NULL);
- break;
-
- case CXCMD_DISABLE:
- ActivateCxObj (broker, 0L);
- break;
-
- case CXCMD_ENABLE:
- ActivateCxObj (broker, 1L);
- break;
-
- case CXCMD_KILL:
- returnvalue = 0L;
- break;
-
- case CXCMD_UNIQUE:
-
- returnvalue = 0L;
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- }
-
- return (returnvalue);
- }
-
- main (int argc, char **argv)
- {
-
- /* For AmigaDOS 2.xx or later */
- {
- extern struct Library *DOSBase;
-
- if (((struct DosLibrary *) DOSBase)->dl_lib.lib_Version < 37)
- exit (RETURN_ERROR);
- }
-
- {
- char **ttypes;
-
- if (CxBase = OpenLibrary ("commodities.library", 37L))
- {
- if (IconBase = OpenLibrary ("icon.library", 36L))
- {
- if (broker_mp = CreateMsgPort ())
- {
- newbroker.nb_Port = broker_mp;
- cxsigflag = 1L << broker_mp->mp_SigBit;
-
- ttypes = ArgArrayInit (argc, argv);
-
- donotwait = (BYTE) ArgInt (ttypes, "DONOTWAIT", NULL);
-
- newbroker.nb_Pri = (BYTE) ArgInt (ttypes, "CX_PRIORITY", 0);
-
- Project0Top = (UWORD) ArgInt (ttypes, "YPOSITION", 26);
- Project0Left = (UWORD) ArgInt (ttypes, "XPOSITION", 83);
-
- cx_popup = (stricmp ("NO", ArgString (ttypes, "CX_POPUP", "TRUE")) == 0) ? FALSE : TRUE;
-
- cx_popkey = ArgString (ttypes, "CX_POPKEY", "ctrl lalt u");
-
- database = ArgString (ttypes, "DATABASE", NULL);
-
- if (broker = CxBroker (&newbroker, NULL))
- {
- if (filter = CxFilter (cx_popkey))
- {
-
- AttachCxObj (broker, filter);
-
- if (sender = CxSender (broker_mp, EVT_HOTKEY))
- {
- AttachCxObj (filter, sender);
-
- if (translate = (CxTranslate (NULL)))
- {
- AttachCxObj (filter, translate);
-
- if (!CxObjError (filter))
- {
- UPSey ();
- }
- }
- }
- }
-
- DeleteCxObjAll (broker);
- }
-
- DeletePort (broker_mp);
- }
-
- ArgArrayDone ();
- CloseLibrary (IconBase);
- }
- CloseLibrary (CxBase);
- }
- }
- }
-
-
- int
- UPSey (void)
- {
-
- /* open the libraries */
- IntuitionBase = (struct IntuitionBase *) OpenLibrary ((UBYTE *) "intuition.library", LIBRARY_MINIMUM);
- GfxBase = (struct GfxBase *) OpenLibrary ((UBYTE *) "graphics.library", LIBRARY_MINIMUM);
- GadToolsBase = OpenLibrary ((UBYTE *) "gadtools.library", LIBRARY_MINIMUM);
- DiskFontBase = OpenLibrary ((UBYTE *) "diskfont.library", LIBRARY_MINIMUM);
- UtilityBase = OpenLibrary ((UBYTE *) "utility.library", LIBRARY_MINIMUM);
- AslBase = OpenLibrary ((UBYTE *) "asl.library", LIBRARY_MINIMUM);
- ReqToolsBase = (struct ReqToolsBase *) OpenLibrary ((UBYTE *) "reqtools.library", LIBRARY_MINIMUM);
-
- if (!IntuitionBase || !GfxBase || !GadToolsBase || !DiskFontBase || !UtilityBase || !AslBase || !ReqToolsBase)
- {
- printf ("oops! Library opening problem!\n");
- goto oops;
- }
-
- if (SetupScreen ())
- {
- printf ("oops! Screen opening problem!\n");
- goto oops;
-
- }
-
- NewList (&record_list);
-
- if (GetRecordList (&record_list, (STRPTR) database))
- {
- /* Our IDCMP signal */
-
- if (cx_popup == TRUE)
- {
- Project0OpenWindow ();
- }
-
- ActivateCxObj (broker, 1L);
-
- while (1) /* MAIN PROGRAM LOOP */
- {
- ULONG sig_a = intuisigflag; /* Our Intuition signal */
-
- ULONG sig_b = cxsigflag; /* Our CX signal */
-
- ULONG sigr = 0L;
-
- /* Wait for something to happen */
-
- sigr = Wait (sig_a | sig_b);
-
- if (sigr & sig_a) /* Process Intuition messages */
- {
- if (HandleProject0IDCMP () == NULL)
- break;
- }
- else if (sigr & cxsigflag)
- {
- if (ProcessCXMsg () == NULL)
- break;
- }
- }
-
- ActivateCxObj (broker, 0L);
-
- if (Project0Wnd)
- Project0CloseWindow ((struct IntuiMessage *) NULL);
-
- FreeRecordList (&record_list);
-
- }
- else
- {
-
- rtEZRequestTags (" UPSey: FATAL ERROR: Unable to locate database file.\n"
- " Please read UPSey.guide for help\n",
- "Continue",
- NULL,
- NULL,
- RT_ReqPos, (ULONG *) REQPOS_CENTERSCR,
- TAG_END);
-
- }
-
-
- oops:
-
- if (Project0Wnd)
- Project0CloseWindow ((struct IntuiMessage *) NULL);
-
- if (Scr)
- CloseDownScreen ();
-
- if (ReqToolsBase)
- {
- CloseLibrary ((struct Library *) ReqToolsBase);
- ReqToolsBase = NULL;
- }
-
- if (AslBase)
- {
- CloseLibrary ((struct Library *) AslBase);
- AslBase = NULL;
- }
-
- if (UtilityBase)
- {
- CloseLibrary ((struct Library *) UtilityBase);
- UtilityBase = NULL;
- }
-
- if (DiskFontBase)
- {
- CloseLibrary ((struct Library *) DiskFontBase);
- DiskFontBase = NULL;
- }
-
- if (GadToolsBase)
- {
- CloseLibrary ((struct Library *) GadToolsBase);
-
- }
-
- if (GfxBase)
- {
- CloseLibrary ((struct Library *) GfxBase);
- GfxBase = NULL;
- }
-
- if (IntuitionBase)
- {
- CloseLibrary ((struct Library *) IntuitionBase);
- IntuitionBase = NULL;
- }
- }
-